﻿<?php require_once('../Connections/hitekforyou.php'); ?>
<?php

require_once('checklogin.php');
error_reporting(0);
// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');

// Load the KT_back class
require_once('../includes/nxt/KT_back.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("../");

// Make unified connection variable
$conn_hitekforyou = new KT_connection($hitekforyou, $database_hitekforyou);

// Start trigger
$formValidation = new tNG_FormValidation();
$formValidation->addField("idSP", true, "numeric", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("Chipset", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("CPU", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("Ram", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("Manhinh", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("HDD", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("CDRom", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("CardManhinh", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$formValidation->addField("Wifi", true, "text", "", "", "", "Vui lòng điền đúng dữ liệu cần");
$tNGs->prepareValidation($formValidation);
// End trigger

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_hitekforyou, $hitekforyou);
$query_Recordset1 = "SELECT idSP, idSP FROM sanpham ORDER BY idSP";
$Recordset1 = mysql_query($query_Recordset1, $hitekforyou) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

// Make a logout transaction instance
$logoutTransaction = new tNG_logoutTransaction($conn_hitekforyou);
$tNGs->addTransaction($logoutTransaction);
// Register triggers
$logoutTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "GET", "KT_logout_now");
$logoutTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "login.php");
// Add columns
// End of logout transaction instance

// Make an insert transaction instance
$ins_chitietsp = new tNG_multipleInsert($conn_hitekforyou);
$tNGs->addTransaction($ins_chitietsp);
// Register triggers
$ins_chitietsp->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_chitietsp->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$ins_chitietsp->registerTrigger("END", "Trigger_Default_Redirect", 99, "../includes/nxt/back.php");
// Add columns
$ins_chitietsp->setTable("chitietsp");
$ins_chitietsp->addColumn("idSP", "NUMERIC_TYPE", "POST", "idSP");
$ins_chitietsp->addColumn("Chipset", "STRING_TYPE", "POST", "Chipset");
$ins_chitietsp->addColumn("CPU", "STRING_TYPE", "POST", "CPU");
$ins_chitietsp->addColumn("Ram", "STRING_TYPE", "POST", "Ram");
$ins_chitietsp->addColumn("Manhinh", "STRING_TYPE", "POST", "Manhinh");
$ins_chitietsp->addColumn("HDD", "STRING_TYPE", "POST", "HDD");
$ins_chitietsp->addColumn("CDRom", "STRING_TYPE", "POST", "CDRom");
$ins_chitietsp->addColumn("CardManhinh", "STRING_TYPE", "POST", "CardManhinh");
$ins_chitietsp->addColumn("Wifi", "STRING_TYPE", "POST", "Wifi");
$ins_chitietsp->setPrimaryKey("idChitietSP", "NUMERIC_TYPE");

// Make an update transaction instance
$upd_chitietsp = new tNG_multipleUpdate($conn_hitekforyou);
$tNGs->addTransaction($upd_chitietsp);
// Register triggers
$upd_chitietsp->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");
$upd_chitietsp->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$upd_chitietsp->registerTrigger("END", "Trigger_Default_Redirect", 99, "../includes/nxt/back.php");
// Add columns
$upd_chitietsp->setTable("chitietsp");
$upd_chitietsp->addColumn("idSP", "NUMERIC_TYPE", "POST", "idSP");
$upd_chitietsp->addColumn("Chipset", "STRING_TYPE", "POST", "Chipset");
$upd_chitietsp->addColumn("CPU", "STRING_TYPE", "POST", "CPU");
$upd_chitietsp->addColumn("Ram", "STRING_TYPE", "POST", "Ram");
$upd_chitietsp->addColumn("Manhinh", "STRING_TYPE", "POST", "Manhinh");
$upd_chitietsp->addColumn("HDD", "STRING_TYPE", "POST", "HDD");
$upd_chitietsp->addColumn("CDRom", "STRING_TYPE", "POST", "CDRom");
$upd_chitietsp->addColumn("CardManhinh", "STRING_TYPE", "POST", "CardManhinh");
$upd_chitietsp->addColumn("Wifi", "STRING_TYPE", "POST", "Wifi");
$upd_chitietsp->setPrimaryKey("idChitietSP", "NUMERIC_TYPE", "GET", "idChitietSP");

// Make an instance of the transaction object
$del_chitietsp = new tNG_multipleDelete($conn_hitekforyou);
$tNGs->addTransaction($del_chitietsp);
// Register triggers
$del_chitietsp->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Delete1");
$del_chitietsp->registerTrigger("END", "Trigger_Default_Redirect", 99, "../includes/nxt/back.php");
// Add columns
$del_chitietsp->setTable("chitietsp");
$del_chitietsp->setPrimaryKey("idChitietSP", "NUMERIC_TYPE", "GET", "idChitietSP");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);

// Get the transaction recordset
$rschitietsp = $tNGs->getRecordset("chitietsp");
$row_rschitietsp = mysql_fetch_assoc($rschitietsp);
$totalRows_rschitietsp = mysql_num_rows($rschitietsp);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="quantri.css" rel="stylesheet" type="text/css" />
<script src="../AC_RunActiveContent.js" type="text/javascript"></script>

<title>Quản trị web HitekForYou</title>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script><?php echo $tNGs->displayValidationRules();?><script src="../includes/nxt/scripts/form.js" type="text/javascript"></script><script src="../includes/nxt/scripts/form.js.php" type="text/javascript"></script><script type="text/javascript">
$NXT_FORM_SETTINGS = {
  duplicate_buttons: true,
  show_as_grid: true,
  merge_down_value: true
}
</script>
</head>

<body>

<?php include("admin_template/header.php"); ?>
<?php include("admin_template/admin_banner.php"); ?> 
<table id="main" width="990" border="1" align="center" cellpadding="0" cellspacing="0">
 <tr>
    <td width="200" align="left" valign="top" bgcolor="#66CC00" id="cottrai">
      <div align="left">
      <?php include("menu.php"); ?>  
      </div>       </td>
    <td id="cotphai" width="790" align="left" valign="top" bgcolor="#CCFF00">
    
  
   
<div class="KT_tng">
  <h1>
    <?php 
// Show IF Conditional region1 
if (@$_GET['idChitietSP'] == "") {
?>
    Thêm
    <?php 
// else Conditional region1
} else { ?>
    Cập nhật
    <?php } 
// endif Conditional region1
?>
    Chi tiết sản phẩm </h1>
  <div class="KT_tngform">
    <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
      <?php $cnt1 = 0; ?>
      <?php do { ?>
      <?php $cnt1++; ?>
      <?php 
// Show IF Conditional region1 
if (@$totalRows_rschitietsp > 1) {
?>
      <h2><?php echo NXT_getResource("Record_FH"); ?> <?php echo $cnt1; ?></h2>
      <?php } 
// endif Conditional region1
?>
      <table cellpadding="2" cellspacing="0" class="KT_tngtable">
        <tr>
          <td class="KT_th"><label for="idSP_<?php echo $cnt1; ?>">ID Sản phẩm:</label></td>
          <td><select name="idSP_<?php echo $cnt1; ?>" id="idSP_<?php echo $cnt1; ?>">
            <option value=""><?php echo NXT_getResource("Select one..."); ?></option>
            <?php 
do {  
?>
            <option value="<?php echo $row_Recordset1['idSP']?>"<?php if (!(strcmp($row_Recordset1['idSP'], $row_rschitietsp['idSP']))) {echo "SELECTED";} ?>><?php echo $row_Recordset1['idSP']?></option>
            <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
          </select>
              <?php echo $tNGs->displayFieldError("chitietsp", "idSP", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="Chipset_<?php echo $cnt1; ?>">Chip:</label></td>
          <td><input type="text" name="Chipset_<?php echo $cnt1; ?>" id="Chipset_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['Chipset']); ?>" size="32" maxlength="255" />
              <?php echo $tNGs->displayFieldHint("Chipset");?> <?php echo $tNGs->displayFieldError("chitietsp", "Chipset", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="CPU_<?php echo $cnt1; ?>">CPU:</label></td>
          <td><input type="text" name="CPU_<?php echo $cnt1; ?>" id="CPU_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['CPU']); ?>" size="32" maxlength="255" />
              <?php echo $tNGs->displayFieldHint("CPU");?> <?php echo $tNGs->displayFieldError("chitietsp", "CPU", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="Ram_<?php echo $cnt1; ?>">Ram:</label></td>
          <td><input type="text" name="Ram_<?php echo $cnt1; ?>" id="Ram_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['Ram']); ?>" size="32" maxlength="50" />
              <?php echo $tNGs->displayFieldHint("Ram");?> <?php echo $tNGs->displayFieldError("chitietsp", "Ram", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="Manhinh_<?php echo $cnt1; ?>">Màn hình:</label></td>
          <td><input type="text" name="Manhinh_<?php echo $cnt1; ?>" id="Manhinh_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['Manhinh']); ?>" size="32" maxlength="20" />
              <?php echo $tNGs->displayFieldHint("Manhinh");?> <?php echo $tNGs->displayFieldError("chitietsp", "Manhinh", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="HDD_<?php echo $cnt1; ?>">HDD:</label></td>
          <td><input type="text" name="HDD_<?php echo $cnt1; ?>" id="HDD_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['HDD']); ?>" size="32" maxlength="50" />
              <?php echo $tNGs->displayFieldHint("HDD");?> <?php echo $tNGs->displayFieldError("chitietsp", "HDD", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="CDRom_<?php echo $cnt1; ?>">CDRom:</label></td>
          <td><input type="text" name="CDRom_<?php echo $cnt1; ?>" id="CDRom_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['CDRom']); ?>" size="32" maxlength="50" />
              <?php echo $tNGs->displayFieldHint("CDRom");?> <?php echo $tNGs->displayFieldError("chitietsp", "CDRom", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="CardManhinh_<?php echo $cnt1; ?>">Card Màn hình:</label></td>
          <td><input type="text" name="CardManhinh_<?php echo $cnt1; ?>" id="CardManhinh_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['CardManhinh']); ?>" size="32" maxlength="50" />
              <?php echo $tNGs->displayFieldHint("CardManhinh");?> <?php echo $tNGs->displayFieldError("chitietsp", "CardManhinh", $cnt1); ?> </td>
        </tr>
        <tr>
          <td class="KT_th"><label for="Wifi_<?php echo $cnt1; ?>">Wifi:</label></td>
          <td><input type="text" name="Wifi_<?php echo $cnt1; ?>" id="Wifi_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rschitietsp['Wifi']); ?>" size="32" maxlength="50" />
              <?php echo $tNGs->displayFieldHint("Wifi");?> <?php echo $tNGs->displayFieldError("chitietsp", "Wifi", $cnt1); ?> </td>
        </tr>
      </table>
      <input type="hidden" name="kt_pk_chitietsp_<?php echo $cnt1; ?>" class="id_field" value="<?php echo KT_escapeAttribute($row_rschitietsp['kt_pk_chitietsp']); ?>" />
      <?php } while ($row_rschitietsp = mysql_fetch_assoc($rschitietsp)); ?>
      <div class="KT_bottombuttons">
        <div>
          <?php 
      // Show IF Conditional region1
      if (@$_GET['idChitietSP'] == "") {
      ?>
          <input type="submit" name="KT_Insert1" id="KT_Insert1" value="Thêm" />
          <?php 
      // else Conditional region1
      } else { ?>
          <div class="KT_operations">
            <input type="submit" name="KT_Insert1" value="Thêm mới" onclick="nxt_form_insertasnew(this, 'idChitietSP')" />
          </div>
          <input type="submit" name="KT_Update1" value="Cập nhật" />
          <input type="submit" name="KT_Delete1" value="Xóa" onclick="return confirm('<?php echo NXT_getResource("Bạn có chắc muốn xóa ?"); ?>');" />
          <?php }
      // endif Conditional region1
      ?>
          <input type="button" name="KT_Cancel1" value="Hủy" onclick="return UNI_navigateCancel(event, '../includes/nxt/back.php')" />
        </div>
      </div>
    </form>
  </div>
  <br class="clearfixplain" />
</div>
<p>&nbsp;</p>
</tr>
</table>
<?php include("admin_template/footer.php"); ?>  
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

